package tests;

import static org.junit.Assert.*;

import java.sql.Timestamp;
import java.util.Date;

import model.Email;
import model.EmailBuilder;
import model.MeetingBuilder;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
 * This class tests the Email Builder class.
 * 
 * @author b_aldosa
 *
 */
public class TestEmailBuilder {

	EmailBuilder SUT;
	
	/**
	 * This method is called before every test case to initialize
	 * the Email Builder object
	 */
	@Before
	public void setUp()
	{
		SUT=new EmailBuilder();
	}
	
	/**
	 * This method is called after each test case to nullify
	 * the Email Builder object
	 */
	@After
	public void tearDown()
	{
		SUT=null;
	}
	
	/**
	 * This test case tests the set to method
	 */
	@Test
	public void testSetTo() {
	SUT.setTo("to");
	assertEquals("to",SUT.getTo());
	}
	
	/**
	 * This test case tests the set from method
	 */
	@Test
	public void testSetFrom() {
		SUT.setFrom("from");
		assertEquals("from",SUT.getFrom());
	}
	/**
	 * This test case tests the set subject method
	 */
	@Test
	public void testSetSubject() {
		SUT.setSubject("subject");
		assertEquals("subject",SUT.getSubject());
	}
	/**
	 * This test case tests the set body method
	 */
	@Test
	public void testSetBody() {
		SUT.setBody("body");
		assertEquals("body",SUT.getBody());
	}
	/**
	 * This test case tests the set read method
	 */
	@Test
	public void testSetRead() {
		SUT.setRead(false);
		assertFalse(SUT.isRead());
	}
	/**
	 * This test case tests the set timestamp method
	 */
	@Test
	public void testSetTimestamp() {
		Date date= new Date();
		Timestamp currentTime=(new Timestamp(date.getTime()));
		
		SUT.setTimestamp(currentTime);
		assertEquals(currentTime,SUT.getTimestamp());
		
	}
	/**
	 * This test case tests the set id method
	 */
	@Test
	public void testSetId() {
		SUT.setId(0);
		assertEquals(0,SUT.getId());
	}
	/**
	 * This test case tests the set pending recipients method
	 */
	@Test
	public void testSetPendingRecepients() {
		SUT.setPendingRecepients("recipients");
		assertEquals("recipients",SUT.getPendingRecipients());
	}
	/**
	 * This test case tests the build method
	 */
	@Test
	public void testBuild() {
		Date date= new Date();
		Timestamp currentTime=(new Timestamp(date.getTime()));
		
		Email em=SUT.setBody("body")
				.setFrom("from")
				.setTo("to")
				.setId(0)
				.setPendingRecepients("recipients")
				.setRead(false)
				.setSubject("subject")
				.setTimestamp(currentTime)
				.build();
		assertNotNull(em);
		
	}
	/**
	 * This test case tests the get to method
	 */
	@Test
	public void testGetTo() {
		SUT.setTo("to");
		assertEquals("to",SUT.getTo());
	}
	/**
	 * This test case tests the get from method
	 */
	@Test
	public void testGetFrom() {
		SUT.setFrom("from");
		assertEquals("from",SUT.getFrom());
	}
	/**
	 * This test case tests the get subject method
	 */
	@Test
	public void testGetSubject() {
		SUT.setSubject("subject");
		assertEquals("subject",SUT.getSubject());
	}
	/**
	 * This test case tests the get body method
	 */
	@Test
	public void testGetBody() {
		SUT.setBody("body");
		assertEquals("body",SUT.getBody());
	}
	/**
	 * This test case tests the is read method
	 */
	@Test
	public void testIsRead() {
		SUT.setRead(false);
		assertFalse(SUT.isRead());
	}
	/**
	 * This test case tests the get timestamp method
	 */
	@Test
	public void testGetTimestamp() {
		assertEquals("class java.sql.Timestamp",SUT.getTimestamp().getClass().toString());
	}
	/**
	 * This test case tests the get id method
	 */
	@Test
	public void testGetId() {
		SUT.setId(0);
		assertEquals(0,SUT.getId());
	}
	/**
	 * This test case tests the get pending recipients method
	 */
	@Test
	public void testGetPendingRecipients() {
		SUT.setPendingRecepients("recipients");
		assertEquals("recipients",SUT.getPendingRecipients());
	}

}
